package easy;

import util.PrintUtils;

public class Solution_1323 {

    public int maximum69Number(int num) {
        int count = -1, i = 0, temp = num;
        while (temp > 0) {
            int mod = temp % 10;
            if (mod == 6) {
                count = i;
            }
            temp /= 10;
            i++;
        }
        int a = 1;
        for (int j = 0; j < count; j++) {
            a *= 10;
        }
        return num + (count >= 0 ? 3 * a : 0);
    }

    public static void main(String[] args) {
        Solution_1323 model = new Solution_1323();
        System.out.println(model.maximum69Number(9669));
        System.out.println(model.maximum69Number(9996));
        System.out.println(model.maximum69Number(9999));
    }
}
